
#include <QPicture>
#include <QPixmap>
#include <QPalette>
#include "aboutobjectdialog.h"
#include "ui_aboutobjectdialog.h"
#include "virtualfsobject.h"
#include "utils.h"


AboutObjectDialog::AboutObjectDialog(const QString & f, VirtualFsObject *obj, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AboutObjectDialog)
{
    Q_UNUSED(f)

    ui->setupUi(this);

    bool dir = obj->isDir();
    QString realfile = obj->realWay() + obj->realName();
    QString range = "hz";
    QFile rfile(realfile);


    quint64 sz = Utils::bytesToHigherDimensions(rfile.size(), range);

    ui->virt->setText( obj->virtualWay() + "/" + obj->name() );
    ui->real->setText( dir? "virtual folder has no real way": realfile );
    ui->size_label->setText( QString("%1 %2 (%3b)").arg(sz).arg(range).arg(rfile.size()) );
    ui->exist_label->setText( dir? "unknow" : rfile.exists()? "Yes": "No" );
    ui->type_label->setText( dir? "Directory" : "File" );
    ui->hidden_label->setText( obj->isHidden()? "Yes" : "No" );

    if(dir)
        ui->icon->setPixmap(QPixmap(":/icons/images/folder.png"));
    else
        ui->icon->setPixmap(QPixmap(":/icons/images/file.png"));

}


AboutObjectDialog::~AboutObjectDialog()
{
    qDebug() << __FUNCTION__ << "removed";
    delete ui;
}


void AboutObjectDialog::closeEvent(QCloseEvent *)
{
    deleteLater();
}


void AboutObjectDialog::on_pushButton_clicked()
{
    close();
}
